﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Xml.Serialization;

namespace CompareCopy
{
    [Serializable]
    public class ConfigData
    {
        private string sourceFolder;
        private List<string> targetFolder = new List<string>();
        private string fileFilter;
        public string SourceFolder
        {
            get
            {
                return sourceFolder;
            }

            set
            {
                sourceFolder = value;
            }
        }

        public List<string> TargetFolder
        {
            get
            {
                return targetFolder;
            }

            set
            {
                targetFolder = value;
            }
        }

        public string FileFilter
        {
            get
            {
                return fileFilter;
            }

            set
            {
                fileFilter = value;
            }
        }
    }
    public class Config
    {
        public static void XMLSerialize(ConfigData config,string filePath)
        {
            XmlSerializer xs = new XmlSerializer(typeof(ConfigData));
            Stream stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read);
            xs.Serialize(stream, config);
            stream.Close();
        }
        public static ConfigData XMLDeserialize(string filePath)
        {
            XmlSerializer xs = new XmlSerializer(typeof(ConfigData));
            Stream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
            ConfigData config = xs.Deserialize(stream) as ConfigData;
          
            stream.Close();

            return config;
        }
    }
}
